package leetcode;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main5 {
    public static void main(String[] args) {
        System.out.println(new Main5().solution1());
    }

    public String[] solution1() {
        // write code here

        List<String> ans = new ArrayList<>();

        String[] dateArr = {"2021-04-30", "2021-05-03"};
        String[] startDate = dateArr[0].split("-");
        String[] endDate = dateArr[1].split("-");

        int yearStart = Integer.valueOf(startDate[0]);
        int yearEnd = Integer.valueOf(endDate[0]);

        int mouthStart = Integer.valueOf(startDate[1]);
        int mouthEnd = Integer.valueOf(endDate[1]);

        int dayStart = Integer.valueOf(startDate[2]);
        int dayEnd = Integer.valueOf(endDate[2]);

        while (yearStart < yearEnd || yearStart == yearEnd && mouthStart <= mouthEnd) {

            // 天
            while (mouthStart == mouthEnd && dayStart <= dayEnd
                    || mouthStart != mouthEnd && dayStart <= 30) {

                StringBuilder date = new StringBuilder();
                date.append(yearStart).append("-")
                        .append(mouthStart < 10 ? "0" + mouthStart : mouthStart).append("-")
                        .append(dayStart < 10 ? "0" + dayStart : dayStart);
                ans.add(date.toString());

                if (dayStart == 30) {
                    mouthStart++;
                    dayStart = 1;
                } else {
                    dayStart++;
                }
            }

            if (yearStart == yearEnd && mouthStart == mouthEnd && dayStart == dayEnd) {
                break;
            }
            if (mouthStart == 13) {
                yearStart++;
                mouthStart = 1;
            }
        }

        return ans.toArray(new String[ans.size()]);
    }

    public int solution(String input) {
        // write code here
        if (input == null || input.length() == 0) {
            return 0;
        }
        char[] arr = input.toCharArray();
        Set<Character> set = new HashSet<>();

        int ans = 1;
        int right = 0, n = arr.length;
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                set.remove(arr[i - 1]);
            }
            while (right < n && !set.contains(arr[right])) {
                set.add(arr[right]);
                right++;
            }
            ans = Math.max(ans, set.size());
        }
        return ans;
    }
}
